import {
  Controller,
  Get,
  Param,
  UseGuards,
  Query,
  DefaultValuePipe,
  ParseIntPipe,
} from '@nestjs/common';
import { GoodsService } from './goods.service';
import { AuthGuard } from 'src/auth/auth.guard';

@Controller('goods')
@UseGuards(AuthGuard)
export class GoodsController {
  constructor(private readonly goodsService: GoodsService) {}

  @Get()
  findAll(
    @Query('pageNum', new DefaultValuePipe(1), ParseIntPipe) pageNum: number,
    @Query('pageSize', new DefaultValuePipe(10), ParseIntPipe) pageSize: number,
  ) {
    return this.goodsService.findAll(pageNum, pageSize);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.goodsService.findOne(+id);
  }
}
